package com.yyq.singleton;

import java.util.HashMap;

public class RegSingleton {
	static private HashMap m_registry = new HashMap();
	static {
		RegSingleton x = new RegSingleton();
		m_registry.put(x.getClass().getName(), x);
	}

	private RegSingleton() {
	}

	static public RegSingleton getInstance(String name) {
		if (null == name) {
			name = "com.yyq.singleton.Regsingleton";
		}
		if (null == m_registry.get(name)

		) {
			try {
				m_registry.put(name, Class.forName(name).newInstance());
			} catch (Exception e) {
				System.out.println("Error happenend.");
			}
		}
		return (RegSingleton) m_registry.get(name);
	}
}
